Page({
    data: {
        args: false
        , page: 1
    }
    , onLoad: function (options) {
        getApp().page.onLoad(this, options);
    }
    , onShow: function () {
        getApp().page.onShow(this);
        var zz_that = this;

        getApp().core.showLoading({
            title: '加载中'
        });

        getApp().request({
            url: getApp().api.draw.prize
            , data: {
                page: 1
            }
            , complete: function() {
                getApp().core.hideLoading();
            }
            , success: function (result) {
                if (result.code == 0) {
                    zz_that.setData({
                        list: result.data
                    })
                    return;
                }
            }
        });
    }
    , onReachBottom: function () {
        getApp().page.onReachBottom(this);
        var zz_that = this;

        if (zz_that.data.args) return false;

        var page = zz_that.data.page + 1;
        getApp().request({
            url: getApp().api.draw.prize
            , data: {
                page: page
            }
            , success: function(result) {
                if (result.code == 0) {
                    zz_that.setData({
                        list: zz_that.data.list.concat(result.data)
                        , page: page
                    })
                } else {
                    zz_that.data.args = true;
                }
            }
        });
    }
    , submit: function(e) {
        var gift = e.currentTarget.dataset.gift;
        var attr = JSON.parse(e.currentTarget.dataset.attr);
        var id = e.currentTarget.dataset.id;

        getApp().core.navigateTo({
            url: '/pages/order-submit/order-submit?chouqian_log_id=' + id + "&goods_info=" + JSON.stringify({
                goods_id: gift
                , attr: attr
                , num: 1
            })
        });
    }
});
